home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / memory / emsaw41s.zip / MAN40.ASC < prev    next >
Text File  |  1994-06-26  |  31KB  |  814 lines

  1.                           "Don't make things complex, make them useful."
  2.                            Andrew Wolfenburg, 1993
  3.  
  4.                  Huge Arrays in Expanded Memory 
  5.           Accessible from Several Computer Languages 
  6.                          ver. 4.1, 4.1S
  7.            
  8.              (c) Copyright A. W. Wolfenburg, 1994
  9.  
  10.             
  11. 1. Instead of Introduction
  12. ---------------------------
  13.    If you are a DOS programmer in C, Pascal, Fortran, Cobol, Clipper, 
  14. or some similar language on the IBM PC compatible and you want to use 
  15. huge arrays (up to 82 MB in total) in your programs and you have 
  16. a beloved compiler that you cannot abandon, my package is for you.
  17.  
  18.    Additionally, if you want to directly address fields with 
  19. lengths (1 to 32 bits) defined by you, and positions of these fields 
  20. are unrestricted in the scope of the arrays (fields may overlap word
  21. boundaries), you will be able to do it with great ease.
  22.  
  23.    You need in your 286 or higher, an extended memory with
  24. suitable size (1, 2, 4, 8 MB or more). A memory manager (e.g. EMM386.EXE
  25. from DOS 5.0) will use this memory as expanded memory according 
  26. to LIM EMS (Expanded Memory Specification) 3.2 or 4.0. If you have a 286
  27. you should use a different memory manager, e.g. shareware EMS40.SYS.
  28.    A 486 50MHz IBM compatible with 64 MB RAM has been successfully
  29. tested for the access to near 64 MB of EMS memory with the Quarterdeck
  30. Memory Manager QEMM386.SYS.
  31.  
  32.    Now, you can forget about such terms as "mapping", "handle",
  33. "frame", "caching", "aliasing", "segment", "offset", "physical
  34. page", "logical page" and so on. In this case there exist only
  35. arrays with a defined number of elements in which defined fields
  36. can be located. 
  37.  
  38.    Let others waste their time reading long and boring descriptions
  39. of extended and expanded memory specifications, you can take advantage
  40. of time saved for solving problems. You can locate up to 32,678-byte
  41. long variables, records, coded characters and bit combinations in the
  42. 1-D, or any-D (up to 32,768-D) array elements and on the defined fields
  43. of a 1-D array, and get back exactly what was put in. You can use up to
  44. 254 arrays according to LIM EMS 4.0 specification.
  45.    For example this package will enable you to store variants of chess 
  46. moves for computer championship matches. 
  47.  
  48.   The EM (expanded memory) can be allocated dynamically to particular 
  49. arrays and can be freed by calling suitable subroutines belonging to the 
  50. package. Before program termination the memory allocated to the arrays 
  51. should be freed, otherwise there may not be enough EMS or XMS memory 
  52. during execution of a later program.
  53.  
  54.   The size of the defined array is constant until the moment of
  55. releasing the memory allocated to this array. Of course, after
  56. memory has been released, program has been terminated or power shut
  57. down, the content of the memory is lost.
  58.  
  59.   The software package has been written in pure assembly code, does not
  60. need to use any libraries, and is very fast.
  61.  
  62.  2. To be specific:
  63. --------------------
  64.  
  65.    Whatever programming languages you use, you deal with
  66. subroutines. Those which return a value are called functions
  67. in some languages. Subroutines compiled outside the main
  68. program are called external subroutines. Several external
  69. subroutines contained in one file and compiled together constitute
  70. a module. The module can have the shape of an object file
  71. (extension .obj). 
  72.    The subroutines of this package are contained in object files.
  73. Basically there are two sets of these subroutines: with the C
  74. calling convention (they are in the file emsw40c.obj) and with the
  75. Pascal calling convention (they are in emsw40p.obj). The third file
  76. segcl.obj contains subroutines which can be used together with
  77. emsw40c.obj in Clipper programs which use Extended System. The Pascal
  78. (Turbo Pascal) calling convention is also used in Fortran and Cobol
  79. on the PC and can be used in these languages. 
  80.    All the parameters (arguments) of the package subroutines are
  81. addresses (pointers) of the type segment:offset and point on two
  82. words in the calling subroutine (except some calls in Clipper 
  83. - see the Clipper program example). This method of parameter
  84. transferring is called "by reference or by pointer".
  85.  
  86.   To run any program with the package subroutines you should have
  87. a Memory Manager installed. For example, if you use DOS 5.0 or
  88. higher you might have in config.sys file the two lines:
  89.  
  90. device=himem.sys
  91. device=emm386.exe <amount_of_mem_in_kilobytes_you_will_use> ram
  92.  
  93. or for 286s:  
  94. device=ems40.sys <amount_of_mem_in_kilobytes_you_will_use>
  95.  
  96.  The subroutines in the package are:
  97. (= means function)
  98.  
  99. EMINIT() - initiates access to expanded memory and should be called
  100. once, as the first, among the rest of the subroutines.
  101.  
  102. SIZEAR(t, f) - gives total t and current available f number of
  103. array elements (4 byte integers) to allocate.
  104.  
  105. NEWAR(A, w) - allocates w 4 byte integer elements for an
  106. array whose description is stored in A, a 2 bytes long system 
  107. variable associated with this array (so, we can call this array A).
  108. You must not change the value of this variable.
  109.  
  110. SETINT(A, w, v) - sets value of the element w of array A to v (A
  111. is 2 bytes long, w and v are 4 byte integers). Elements of arrays 
  112. are counted from 1.
  113.  
  114. =GETINT(A, w) - gets value of the element w of the array A and
  115. returns this value to calling program (unit). GETINT must be 4 byte
  116. integer.
  117.  
  118. GETINTCO(A, w, v) - gets value of the element w of the array A and
  119. assigns this value to v, 4 byte integer variable. This procedure 
  120. can be called instead of GETINT in the languages without functions e.g. 
  121. COBOL.
  122.  
  123. SETF(A, w, b, l, v) - sets value of the field started in w element
  124. of array A from the bit b with length l bits to the value of v. 
  125. Bits in all the elements of an array are counted from 0 to 31 from 
  126. left to right. If the value v is too big to fit in the defined field,
  127. it is cut from the left side to the defined length l. The values of
  128. adjoined fields will always stay unchanged in such a situation.
  129.  
  130. =GETF(A, w, b, l) -  gets value of the field started in w element
  131. of array A from the bit b with length l bits and returns this value 
  132. to the calling program (unit) by assigning it to GETF. The type of 
  133. GETF can be 2 byte integer or 4 byte integer depending on the size 
  134. of the field.
  135.  
  136. GETFCO(A, w, b, l, v) - gets value of the field started in w element
  137. of array A from the bit b with length l and assigns this value to 
  138. the v variable. This procedure can be called instead of GETF in the
  139. languages without functions eg. COBOL.
  140.  
  141. FREEAR(A) - releases the expanded memory allocated for array A.
  142.  
  143.    Additionally for the version 4.0+ some new subroutines were
  144. introduced.
  145.    They enable usage of 1-D, 2-D and 3-D and any D arrays up to 32768-D.
  146. Each element of these arrays can have length 1 to 32768 bytes. The
  147. subroutines are contained in emsw40p.obj file for the Pascal calling
  148. convention, and in emsw40c.obj for C calling convention.
  149.    
  150. These new subroutines are:
  151.  
  152. SIZA (t, f, i) - gives total t and available f amount of elements for
  153. a new array having elements of the length of i bytes.
  154.  
  155. NEWA (A, i, l) - allocates i elements of the length l bytes (up to
  156. 32678) for an 1-D array whose description is stored in a 2 bytes long
  157. system variable A is associated with this array (so, we can call this
  158. array A). You must not change the value of this variable. The variable
  159. i should be at least a 4 byte integer, and variable l should be at least
  160. a 2 byte integer.
  161.  
  162. NEWA2 (A, i, j, l) - allocates i*j  elements of the length l (1 to
  163. 32678) bytes each, for an 2-D array whose description is stored in
  164. a 2 byte long, system variable A, which is associated with this array
  165. (so, we can call this array A). You must not change the value of this
  166. variable. The variables i, j should be at least 4 byte integers and
  167. variable l should be at least a 2 byte integer.
  168.  
  169. NEWA3 (A, i, j, k, l) - allocates i*j*k  elements of the length l
  170. (1 to 32678) bytes each, for a 3-D array whose description is stored
  171. in a 2 byte long, system variab